      SUBROUTINE TOUT(SA,OMEG,TIME,IPLOT,IPLTPE)
C
C
C     SUBROUTINE TOUT COMPUTES THE EULER ANGLES AND RATES
C     WITH RESPECT TO THE LOCAL GEOGRAPHICAL FRAME FOR THE GROUND
C     TESTING SIMULATION OF FSD PROGRAM .
C     IT CALLS ARANGE TO EXTRACT ELEMENT DATA ; DMOMNT TO CALCULATE
C     ELEMENT BENDING MOMENTS AND TENSIONS ; AND WRTPLT TO WRITE
C     TEMPORARY DATA SET FOR PLOTS .
C     MODIFICATION AS OF SEPT. 1977.
C
C
        IMPLICIT REAL*8 (A-H,O-Z)
C
      COMMON/CANTNA/ A(10,3),ADOT(10,3),B(10,3),BDOT(10,3),DIN(10,3),
     .               DINDOT(10,3),DOUT(10,3),DOUTDT(10,3)
C
      COMMON/CONSTS/ PI,TWOPI,RADIAN
C
      COMMON/DMMNT1/ZKBM(6),EMAK(10),EMBK(10),DUMM1(6),
     *    ITORK,IBENDM,ITENSE,ITNS1
C
      COMMON/IPOOL1/ IGRAV,IDAMP,IK,K1,ITIM,IAB,IAPS,IBB,IBPS,NK(10),
     .               LK(10),LLK(10)
C
      COMMON/IMAIN1/IDATE,LSAVE,INOPT,IDIM(5)
C
      COMMON/OUTTWO/ SOLILL,EPSERR
C
      COMMON/XIN1/ PSI1,THET1,PHI1,ETTA,ZETTA,ITEST
C
      COMMON/GRNOUT/ALFAG,DELTG,PHASG,OMGN(3)
C
      COMMON/GRNTST/ALFAEG,DELTAG,PHASEG,ALTUDE,OMGY(3),
     *    GACC(3),GLOCAT(3),IGRUND,IALTUD,IGASBR
C
      DIMENSION H(3),OM(3),OMEG(3),SA(3,3)
C
      ITEST=1
C     COMPUTE THE EULER ANGLES FROM THE SA MATRIX
C
C
C
      IF(IGASBR.EQ.0) GO TO 200
      ALFAG=DATAN2(SA(1,3),SA(2,3))/RADIAN
      DELTG=DARCOS(SA(3,3))/RADIAN
      GO TO 220
 200  CONTINUE
      ALFAG=ALFAEG
      DELTG=DELTAG
 220  CONTINUE
C
      DO 70 I=1,3
 70   OMGN(I)=OMEG(I)/RADIAN
C
      X=ETTA*RADIAN
      Y=ZETTA*RADIAN
      W=SA(1,3)*DSIN(X)*DCOS(Y) + SA(2,3)*DSIN(X)*DSIN(Y)
     .                          + SA(3,3)*DCOS(X)
      EPSERR=DARCOS(W)/RADIAN
C
      DUM=0.0D0
      PHASG=0.0D0
C
C     CALL ARANGE
C
      IF(ITENSE.NE.0.OR.IBENDM.NE.0) CALL DMOMNT
C
      IF(IPLOT.NE.0) CALL WRTPLT(TIME,ALFAG,DELTG,PHASG,OMGN,DUM
     1                          ,DUM,EPSERR,DUM,3)
      INOPT=1
C
      RETURN
      END
